package com.bt.lms.ui.page.teaching.arrange;

import com.bt.lms.ui.action.teaching.arrange.PageCourseDetailBackBtnAction;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

/**
 * 课程详细信息界面
 */
public class PageCourseDetailInfo extends VBox {


    /**
     * 课程详细信息界面宽度
     */
    private double preWidth = 1280;

    /**
     * 课程详细信息界面高度
     */
    private double preHeight = 830;

    public PageCourseDetailInfo() {

        this.setPrefSize(preWidth, preHeight);
        this.setPadding(new Insets(5));
        this.setSpacing(20);

        //顶部横向盒子
        HBox topHBox = new HBox();
        initTopHBox(topHBox);
        //查看课程教学安排横向盒子
        HBox lookTeachingArrangeHBox = new HBox();
        initLookTeachingArrangeHBox(lookTeachingArrangeHBox);
        //网格盒子
        VBox netVBox = new VBox();
        initNetVBox(netVBox);
        //底部盒子
        HBox bottomHBox = new HBox();
        initBottomHBox(bottomHBox);


        //滚动条盒子
        VBox scrollPaneVBox = new VBox();
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
        scrollPane.setContent(scrollPaneVBox);
        scrollPane.setPrefSize(preWidth, preHeight);
        //组件放到滚动条盒子
        scrollPaneVBox.getChildren().addAll(topHBox, lookTeachingArrangeHBox, netVBox, bottomHBox);


        ObservableList<Node> children = this.getChildren();
        children.addAll(scrollPane);


    }

    /**
     * 底部盒子
     *
     * @param bottomHBox
     */
    private void initBottomHBox(HBox bottomHBox) {
        bottomHBox.setAlignment(Pos.CENTER_RIGHT);
        //返回按钮
        Button backBtn = new Button("返回");
        BtnStyle.cancelBtn(backBtn);
        bottomHBox.getChildren().add(backBtn);
        //返回按钮事件
        PageCourseDetailBackBtnAction pageCourseDetailBackBtnAction = new PageCourseDetailBackBtnAction();
        backBtn.setOnAction(pageCourseDetailBackBtnAction);
        backBtn.setCursor(Cursor.HAND);
    }

    /**
     * 网格盒子
     *
     * @param netVBox
     */
    private void initNetVBox(VBox netVBox) {
        netVBox.setSpacing(20);
        netVBox.setPadding(new Insets(20));
        //网格
        GridPane gridPane = new GridPane();
        gridPane.setHgap(30);
        gridPane.setVgap(30);


        //课程名称部分
        //标签
        Label courseNameLab = new Label("课程名称：");
        courseNameLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //教育心理学标签
        Label educationLab = new Label("教育心理学");
        gridPane.add(courseNameLab, 0, 1);
        gridPane.add(educationLab, 1, 1);

        //授课教师部分
        //标签
        Label teacherLab = new Label("授课教师:");
        teacherLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //教师名
        Label teacherNameLab = new Label("张老师");
        gridPane.add(teacherLab, 0, 2);
        gridPane.add(teacherNameLab, 1, 2);

        //学员部分
        //学员标签
        Label stuLab = new Label("学员:");
        stuLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //详细标签
        Label detailLab = new Label("招生计划A:A班(15/30）    >>查看学员");
        gridPane.add(stuLab, 0, 3);
        gridPane.add(detailLab, 1, 3);


        //教学方式部分
        //标签
        Label teachingWayLab = new Label("教学方式:");
        teachingWayLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //详细教学方式标签
        Label detailTeachingWayLab = new Label("面授学习");
        gridPane.add(teachingWayLab, 0, 4);
        gridPane.add(detailTeachingWayLab, 1, 4);

        //开课时间部分
        //标签
        Label startCourseLab = new Label("开课时间：");
        startCourseLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //详细时间
        Label detailStartCourseLab = new Label("2012-09-01");
        gridPane.add(startCourseLab, 0, 5);
        gridPane.add(detailStartCourseLab, 1, 5);

        //结课时间部分
        //标签
        Label finishCourseLab = new Label("结课时间：");
        finishCourseLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //详细时间
        Label detailFinishCourseLab = new Label("2012-10-01");
        gridPane.add(finishCourseLab, 0, 6);
        gridPane.add(detailFinishCourseLab, 1, 6);


        //课程目标部分
        //标签
        Label courseAimLab = new Label("课程目标：");
        courseAimLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //课程目标详情
        Label detailCourseAimLab = new Label("为了更好的开展全国教师……");
        gridPane.add(courseAimLab, 0, 7);
        gridPane.add(detailCourseAimLab, 1, 7);


        //最后修改人部分
        //标签
        Label endPersonLab = new Label("最后修改人");
        endPersonLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //人名标签
        Label nameLab = new Label("李某某");
        gridPane.add(endPersonLab, 0, 8);
        gridPane.add(nameLab, 1, 8);

        //上次修改时间部分
        //标签
        Label lastTimeLab = new Label("上次修改时间");
        lastTimeLab.setFont(Font.font(null, FontWeight.BOLD, null, 16));
        //人名标签
        Label timeLab = new Label("2020-10-01 12：59");
        gridPane.add(lastTimeLab, 0, 9);
        gridPane.add(timeLab, 1, 9);


        ObservableList<Node> children = netVBox.getChildren();
        children.addAll(gridPane);
    }

    /**
     * 查看课程教学安排盒子
     *
     * @param lookTeachingArrangeHBox
     */
    private void initLookTeachingArrangeHBox(HBox lookTeachingArrangeHBox) {
        lookTeachingArrangeHBox.setPadding(new Insets(10));
        //新增教学安排标签
        Label lookTeachingArrangeLab = new Label("查看课程教学安排(必修)");
        //设置字体大小
        lookTeachingArrangeLab.setFont(Font.font(null, FontWeight.BOLD, null, 22));
        lookTeachingArrangeLab.setTextFill(Color.rgb(198, 0, 1));//字体颜色
        lookTeachingArrangeHBox.getChildren().addAll(lookTeachingArrangeLab);
    }

    /**
     * 顶部横向盒子
     *
     * @param topHBox
     */
    private void initTopHBox(HBox topHBox) {
        //顶部横向盒子间距
        topHBox.setPadding(new Insets(20));
        topHBox.setSpacing(20);
        //标签
        Label topLab = new Label("当前位置：🏠>教学管理>教学安排>查看教学安排(必修课)");

        topLab.setFont(new Font(20));
        topHBox.getChildren().add(topLab);
    }
}
